// JavaScript Document

var currentPageIndex = 0;
var currentPage = null;
var choosenPage = null;

function setCurrentPage() {
	currentPage = $('#content > div:first-child');
}

function setInitialCurrentPage() {
	$('#content > div:first-child').addClass("currentPage");
	setCurrentPage();
	choosenPage = currentPage;
}

function addRemoveCurrentPageClass() {
	choosenPage.addClass('currentPage');
	currentPage.removeClass('currentPage');
}

function preparePrevButton() {
	$('.btn-prev').bind('click', function() {
		setCurrentPage();
		choosenPage = currentPage.prevUntil('div').prev();
		console.log(choosenPage); // Always is null
		
		if (choosenPage.length != 0) {
			addRemoveCurrentPageClass();
			currentPage = choosenPage;
		}
		return false;
	});
}

function prepareNextButton() {
	$('.btn-next').bind('click', function() {
		setCurrentPage();
		choosenPage = currentPage.nextUntil('div').next();
		console.log(choosenPage); // Always is null
		
		if (choosenPage.length != 0) {
			addRemoveCurrentPageClass();
			currentPage = choosenPage;
		}
		return false;
	});
}

function prepareNavButtons() {
	preparePrevButton();
	prepareNextButton();
}

function prepareAcordionTabs() {
	
}

$(document).ready(function(e) {
    setInitialCurrentPage();
	prepareNavButtons();
	prepareAcordionTabs();
});